home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Games / WHDLoad / Src / sources / whdload / dbffix.s < prev    next >
Encoding:
Text File  |  2000-08-07  |  2.0 KB  |  80 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Modul.    dbffix.s
  3. ;  :Contents.    routine to fix empty dbf loops
  4. ;        the dbf loop will be replaced by a wait based on the vertical
  5. ;        raster position
  6. ;  :Version.    $Id: dbffix.s 1.3 1999/10/07 20:23:38 jah Exp $
  7. ;  :History.    19.03.99 written based on the stfix routine
  8. ;        07.10.99 some documentation mistakes fixed
  9. ;  :Requires.    -
  10. ;  :Copyright.    Public Domain
  11. ;  :Language.    68000 Assembler
  12. ;  :Translator.    Barfly 2.9
  13. ;  :To Do.
  14. ;---------------------------------------------------------------------------*
  15. ;
  16. ; this will patch sequences of the following form:
  17. ;        move.w    #$xxxx,dn    ;3x3c xxxx
  18. ;    .loop    dbf    dn,.loop    ;51cx fffe
  19. ;
  20. ; if a label PATCHCOUNT does exist, the amount of patches will be count in
  21. ; the memory region specified in A2
  22. ;
  23. ; IN:    A0 = APTR start of memory to patch
  24. ;    A1 = APTR end of memory to patch
  25. ;    A2 = APTR space for patch routine (only if PATCHCOUNT is used)
  26. ; OUT:    A2 = APTR points to the end of patch routine (if PATCHCOUNT is used)
  27.  
  28. _dbffix        movem.l    d0-d1/a0-a1,-(a7)
  29.  
  30.     IFD PATCHCOUNT
  31.         clr.l    (a2)+            ;counters = 0
  32.         clr.l    (a2)+            ;counters = 0
  33.     ENDC
  34.  
  35.         subq.l    #6,a1
  36. .loop        cmp.w    #$fffe,(6,a0)        ;loop distance
  37.         bne    .next
  38.         move.w    (a0),d0
  39.         and.w    #$f1ff,d0
  40.         cmp.w    #$303c,d0        ;move.w #$xxxx,d0
  41.         bne    .next
  42.         move.w    (a0),d0
  43.         and.w    #$0e00,d0        ;register number
  44.         rol.w    #7,d0
  45.         or.w    #$51c8,d0        ;dbf d0,_xxx
  46.         cmp.w    (4,a0),d0
  47.         bne    .next
  48.  
  49.     IFD PATCHCOUNT
  50.         and.w    #7,d0            ;register number
  51.         addq.b    #1,(-8,a2,d0.w)
  52.     ENDC
  53.  
  54.         moveq    #0,d1            ;clear high word
  55.         move.w    (2,a0),d1        ;loop counter
  56.         divu    #34,d1
  57.         move.w    #$4eb9,(a0)+        ;JSR (xxxxxxxx.L)
  58.         pea    (.wait,pc)
  59.         move.l    (a7)+,(a0)+
  60.         move.w    d1,(a0)
  61.  
  62. .next        addq.l    #2,a0
  63.         cmp.l    a0,a1
  64.         bhi    .loop
  65.  
  66.         movem.l    (a7)+,d0-d1/a0-a1
  67.         rts
  68.  
  69. .wait        movem.l    d0-d1/a0,-(a7)
  70.         move.l    (12,a7),a0        ;return PC
  71.         move.w    (a0)+,d1        ;loop counter
  72.         move.l    a0,(12,a7)        ;return PC
  73. .1        move.b    ($dff006),d0
  74. .2        cmp.b    ($dff006),d0
  75.         beq    .2
  76.         dbf    d1,.1
  77.         movem.l    (a7)+,d0-d1/a0
  78.         rts
  79.  
  80.